<template>
    <el-dialog :close-on-click-modal="false"
               :visible.sync="visible"
               title="请选择人员">
        <avue-crud ref="crud"
                   :data="dataList"
                   :option="tableOption"
                   :page="page"
                   :table-loading="dataListLoading"
                   @row-click="handleCurrentRowChange"
        >
            <template #radio="{ row }">
                <el-radio v-model="selectRow" :label="row" @click.stop="">{{ }}</el-radio>
            </template>
        </avue-crud>
        <span slot="footer"
              class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary"
                 @click="dataFormSubmit()">确定</el-button>
    </span>
    </el-dialog>
</template>

<script>
import {tableOption} from '@/crud/customer/custList'
import {departList} from '@/utils/data'

export default {
	data () {
		return {
			visible: false,
			personList: [],
			dataList: [],
			page: {
				total: 0, // 总页数
				currentPage: 1, // 当前页数
				pageSize: 10 // 每页显示多少条
			},
			addOrUpdateVisible: false,
			dataListSelections: [],
			dataListLoading: false,
            selectRow: null,
			tableOption: {
				searchMenuSpan: 6,
				columnBtn: false,
				border: true,
				selection: false,
				index: false,
				indexLabel: '序号',
				stripe: true,
				menuAlign: 'center',
				menuWidth: 200,
				align: 'center',
				refreshBtn: true,
				searchSize: 'mini',
				addBtn: false,
				editBtn: false,
				delBtn: true,
				viewBtn: false,
                menu:false,
				props: {
					label: 'label',
					value: 'value'
				},
				column: [
                    { label: '', prop: 'radio', width: 60 },
                    {
                        label: '员工编号',
                        prop: 'empNo',
                    },
					{
						label: '员工姓名',
						prop: 'empName',
					},
					{
						label: '所属部门',
						prop: 'deptId',
						type: 'select',
						dicData: departList
					},
                ]
			},
		}
	},
	methods: {
		init () {
			this.visible = true
			this.getPersonList()
		},
        handleCurrentRowChange(val) {
            console.log('val:', val);
            
            this.selectRow = val;
        },
		dataFormSubmit () {
            this.visible = false
            this.$emit("confirm", this.selectRow)
		},
		getPersonList () {
			this.$http({
				url: this.$http.adornUrl('/crm/base/emp/page'),
				method: 'get',
				params: this.$http.adornParams(Object.assign({
					current: 1,
					size: 999
				}))
			}).then(({data}) => {
				this.dataList = data.obj.records
			})
		},
	}
}
</script>
